package util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateUtil extends packutil.DateUtil {

	// figure out how to populate this from the DB
	private static List<Date> nyseHolidays = new ArrayList<Date>();

	// TODO: write test cases for all of these utility methods
	public static Date adjustTradeDate(Date d, int offset) {

		Calendar c = Calendar.getInstance();
		c.setTime(d);

		do {
			c.add(Calendar.DATE, offset);
		} while (c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
				|| c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY
				|| nyseHolidays.contains(c.getTime()));
		// TODO: test holiday calendar!!

		return c.getTime();
	}
}